﻿Imports System
Imports System.Collections
Imports System.ComponentModel

Namespace System.Workflow.ComponentModel.Design
    Friend NotInheritable Class ReadonlyEventDescriptor
        Inherits EventDescriptor
        ' Methods
        Friend Sub New(ByVal e As EventDescriptor)
            MyBase.New(e, Nothing)
            Me.realEventDescriptor = e
        End Sub

        Public Overrides Sub AddEventHandler(ByVal component As Object, ByVal value As Delegate)
        End Sub

        Public Overrides Sub RemoveEventHandler(ByVal component As Object, ByVal value As Delegate)
        End Sub


        ' Properties
        Public Overrides ReadOnly Property Attributes As AttributeCollection
            Get
                Dim list As New ArrayList
                Dim attribute As Attribute
                For Each attribute In Me.realEventDescriptor.Attributes
                    If (Not TypeOf attribute Is EditorAttribute AndAlso Not TypeOf attribute Is ReadOnlyAttribute) Then
                        list.Add(attribute)
                    End If
                Next
                list.Add(New ReadOnlyAttribute(True))
                Return New AttributeCollection(DirectCast(list.ToArray(GetType(Attribute)), Attribute()))
            End Get
        End Property

        Public Overrides ReadOnly Property Category As String
            Get
                Return Me.realEventDescriptor.Category
            End Get
        End Property

        Public Overrides ReadOnly Property ComponentType As Type
            Get
                Return Me.realEventDescriptor.ComponentType
            End Get
        End Property

        Public Overrides ReadOnly Property Description As String
            Get
                Return Me.realEventDescriptor.Description
            End Get
        End Property

        Public Overrides ReadOnly Property EventType As Type
            Get
                Return Me.realEventDescriptor.EventType
            End Get
        End Property

        Public Overrides ReadOnly Property IsMulticast As Boolean
            Get
                Return Me.realEventDescriptor.IsMulticast
            End Get
        End Property


        ' Fields
        Private realEventDescriptor As EventDescriptor
    End Class
End Namespace

